package org.example;

import org.example.dao.UserDAOImpl;
import org.example.entity.User;
import org.example.service.UserServiceImpl;

import java.io.Serializable;
import java.sql.SQLException;
import java.time.LocalDateTime;

public class Main implements Serializable {
    public static void main(String[] args) throws SQLException {
//        System.out.println("h");
//        Connection conn = JDBCUtils.getConn();
//        DruidDataSource dataSource = JDBCUtils.getDataSource();
//        System.out.println(conn);
//        System.out.println(dataSource);

//        dao();
//        service();
        add();
    }
    static void dao(){
        //测试DAO
        UserDAOImpl userDAO = new UserDAOImpl();
        User u = new User();
        u.setUserID(1);
        User user = userDAO.selectOne(u);
        System.out.println(user);
    }
    static void service(){
        //测试Service
        UserServiceImpl userService =new UserServiceImpl();
        User u2 = new User();
        u2.setUserID(2);
        User user2 =userService.queryOne(u2);
        System.out.println(user2);
    }
    static void add(){
        //测试添加用户
        UserDAOImpl userDAO = new UserDAOImpl();
        User u = new User(null,"testadd","test123",1,null,"123456489", LocalDateTime.now());
        int i = userDAO.insertUser(u);
        System.out.println(i>0?"添加用户成功":"添加用户失败");
    }
}
